package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.CalAbility;
import com.yowasa.xiuxian.engine.battle.strategy.InherentStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.entity.enums.InherentTiming;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@BS(name="神樱神游")
@Order(1000)
@Component
public class ShenYingShenYou extends CalAbility implements InherentStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }
    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int atk = first.getBattleInfo().getSpell();
        int def = second.getBattleInfo().getRes() ;
        int dmg = (int) (battleHelper.calSpell(atk, def) * 0.5);
        second.getBattleInfo().setChp(second.getBattleInfo().getChp() - dmg);
        first.getBattleInfo().setCmp(first.getBattleInfo().getCmp() + dmg);
        content.getMsgLog().add("神樱神游造成了"+dmg+"点伤害，并为你回复了"+dmg+"点法力值");
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("该战技无法直接学习，需要拥有 法器-[神乐之真意] ，装备在身上时自动学会");

    }

    @Override
    public String limitDesc() {
        return "学习/使用神樱神游需要拥有 法器-[神乐之真意] ";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        return true;
    }

    @Override
    public String desc() {
        return "狐狸化作的巫女，在神樱树下跳起祭祀的舞蹈，对敌人引来天雷的惩罚\n对方回合结束后，会受到你的法强*0.5的伤害，并为你回复此次伤害值的mp";
    }

    @Override
    public List<InherentTiming> getTiming() {
        return Lists.newArrayList(InherentTiming.OPPONENT_END);
    }
}
